/*
 * @Author: yxfan
 * @Date: 2024-12-16 18:31:34
 * @LastEditTime: 2025-01-11 17:53:40
 * @FilePath: /umi-demo/src/pages/test/redux/Son.jsx
 * @Description:
 */
import { memo } from 'react';
import { useSelector, useDispatch } from 'umi';
import { useBearStoreShallow } from './store';

export default () => {
    const { name, dispatch } = useBearStoreShallow(({ name, dispatch }) => ({
        name,
        dispatch,
    }));

    console.log('son render');
    function change() {
        dispatch({ type: 'redux/addNum', payload: 100 });
    }

    function change2() {
        increasePopulation();
    }

    function change3() {
        // useBearStore.setState({ name: beforeV + 'yxfan' });
        dispatch({ type: 'setName', payload: name + 'yxfan' });
        console.log('useBearStore', useBearStoreShallow.getState());
    }
    return (
        <div>
            <h3>子组件</h3>
            <button onClick={change}>change</button>
            <button onClick={change2}>zustand change</button>
            <button onClick={change3}>zustand change</button>
        </div>
    );
};
